package com.juzi.wopu.service.impl;

import java.util.List;
import java.util.Map;

import com.juzi.wopu.domain.SysUserRole;
import com.juzi.wopu.query.SysUserRoleQuery;
import com.juzi.wopu.service.ISysUserRoleService;

public class SysUserRoleServiceImpl extends BaseServiceImpl<SysUserRole> implements ISysUserRoleService{

	@Override
	public void getSysUserRoleMap(Map<Long, SysUserRole> map1) {
		List<SysUserRole> list=BaseDao.getAll(SysUserRole.class);
		if(list!=null && list.size()>0){
			if(map1!=null){
				for(SysUserRole s:list){
					map1.put(s.getiUserId(), s);
				}
			}
		}
		
	}

	@Override
	public void deleteByQuery(SysUserRoleQuery sysUserRole) {
		String sql="delete from [pm].[dbo].[tSysUserRole] where 1=1";
		Long iCompany=sysUserRole.getICompany();
		Long iUserId=sysUserRole.getiUserId();
		Long iRole=sysUserRole.getiRole();
		if (iCompany!=null && iCompany!=-1L) {
			sql=sql+" and iCompany="+iCompany;
		}
		
		if (iUserId!=null && iUserId!=-1L) {
			sql=sql+" and iUserId="+iUserId;
		}
		
		if (iRole!=null && iRole!=-1L) {
			sql=sql+" and iRole="+iRole;
		}
		BaseDao.executeSql(sql); 
	}
}

